package com.atwisdom.star.controller;

import com.atwisdom.star.auth.business.Impl.*;
import com.atwisdom.star.auth.pojo.*;
import com.atwisdom.star.common.vo.ActionData;
import com.atwisdom.star.common.vo.LoginInfo;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.log.aop.StarAnnotation;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private UserAccountBslServiceImpl userAccountBslService;
    @Autowired
    private MenuBslServiceImpl menuBslService;
    @Autowired
    private PrivilegeBslServiceImpl privilegeBslService;
    @Autowired
    private RoleBslServiceImpl roleBslService;
    @Autowired
    private RolegpBslServiceImpl rolegpBslService;
    @Autowired
    private AccountRoleBslServiceImpl accountRoleBslService;
    @Autowired
    private RolegpRoleBslServiceImpl rolegpRoleBslService;


    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/user")
    public ResultInfo<?> responseUserFactory(@RequestBody List<ActionData<UserAccount>> actionDataList) {
        return userAccountBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/menu")
    public ResultInfo<?> responseMenuFactory(@RequestBody List<ActionData<Menu>> actionDataList)  {
        return menuBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/privilege")
    public ResultInfo<?> responsePrivilegeFactory(@RequestBody List<ActionData<Privilege>> actionDataList) {
        return privilegeBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/role")
    public ResultInfo<?> responseRoleFactory(@RequestBody List<ActionData<Role>> actionDataList)  {
        return roleBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/rolegp")
    public ResultInfo<?> responseRolegpFactory(@RequestBody  List<ActionData<Rolegp>> actionDataList) {
        return rolegpBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/rolegpRole")
    public ResultInfo<?> responseRolegpRoleFactory(@RequestBody  List<ActionData<RolegpRole>> actionDataList) {
        return rolegpRoleBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param actionDataList 接收参数据
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/accountRole")
    public ResultInfo<?> responseUserRoleFactory(@RequestBody List<ActionData<AccountRole>> actionDataList)  {
        return accountRoleBslService.responseFactory(actionDataList);
    }

    /**
     *
     * @param param 账号ID
     * @return 返回结果
     */
    @StarAnnotation
    @PostMapping(value = "/menuByUserId")
    @ResponseBody
    public ResultInfo<?> getMenuList(@RequestBody Map<String,String> param) {
        return menuBslService.getMenuList(param);
    }

    /**
     * 静态密码登录
     * @param param 登录参数
     * @return 返回结果
     */
    @ApiOperation(value = "系统登录", notes = "系统登录")
    @PostMapping(value = "/login")
    @ResponseBody
    public LoginInfo<UserAccount> login(@RequestBody Map<String,String> param){
        return userAccountBslService.Login(param);
    }
}
